/*
 * ResourceFactory.cpp
 *
 *  Created on: 16 nov. 2010
 *      Author: seeme
 */

#include "ResourceFactory.h"
#include "TextBased/TextFile.h"
#include "TextBased/Shaders/Shader.h"
#include "Textures/Texture.h"
#include "Level/Level.h"
#include "Models/Mesh.h"
#include "../../LogManager/Log.hpp"
#include "../../Scene/Entity/AbstractEntity.h"

Resource* ResourceFactory::buildResource(std::string name, std::string id, std::string realPath){
	if(id == "txt"){
		Log::v("ResourceFactory") << "Creating a new text file:" << name;
		return new TextFile(name, realPath);
	}

	if(id == "lvl"){
		Log::v("ResourceFactory") << "Creating a new level:" << name;
			return new Level(name, realPath);
	}

	if(id == "mesh"){
		Log::v("ResourceFactory") << "Creating a new mesh: " << name;
			return new Mesh(name, realPath);
	}

	if(id == "Vshader"){
		Log::v("ResourceFactory") << "Creating a new vshader shader:" << name;
			return new Shader(name, realPath, GL_VERTEX_SHADER);
	}

	if(id == "Fshader"){
		Log::v("ResourceFactory") << "Creating a new fshader shader:" << name;
			return new Shader(name, realPath, GL_FRAGMENT_SHADER);
	}

	if(id == "texture"){
		Log::v("ResourceFactory") << "Creating a new texture:" << name;
			return new Texture(name, realPath);
	}

	Log::e("RessourceFactory") << "Error unknown build parameter " << name << ", " << id;
	//Never reached
	return NULL;
}

ResourceFactory::ResourceFactory(){
}

ResourceFactory::~ResourceFactory(){
}
